perm filename A41.TEX[106,PHY] blob sn#807781 filedate 1985-10-04 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	\magnification\magstephalf
C00009 ENDMK
C⊗;
\magnification\magstephalf
\input macro.tex
\def\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space\number\day, \number\year}
\baselineskip 14pt
\rm
\line{\sevenrm a41.tex[106,phy] \today\hfill}

\bigskip
\noindent {\bf Page Grids, or Don't yell out the screen door, you'll
strain your voice.}

The page printed by a typical printer used for computer output is an array
about 60~characters wide and 132~characters wide. The characters are
printed within imaginary rectangles, each about 1/6~inch high and 1/10~inch
wide, making up what we call the {\it page grid\/}. We use array coordinates
{\tt RE[1..60]} and {\tt CE[1..132]} to refer to individual rectangles. To refer
to arbitrary geometric points on the page, we use graph coordinates, with
the origin in the upper left corner. Then the rectangle with array
coordinates $(R,C)$ contains the points~$(X,Y)$ such that
${\tt TRUNC}(10X)+1=C$, $-{\tt TRUNC}(6Y)+1=R$; equivalently,
${C-1\over 10}≤X<{C\over 10}$, ${R-1\over 6}≤-Y≤{R\over 6}$. 
(Points on boundaries are associated with the smaller value of~$C$ or~$R$.)

Suppose we want to print a straight line segment on the page, as shown below.

\bigskip
$$\vbox{\tabskip0pt\offinterlineskip
\halign{\strut#&\vrule#&$\;$\hfil{\tt #}\hfil$\;$%
&$\;$\hfil{\tt #}\hfil$\;$%
&$\;$\hfil{\tt #}\hfil$\;$%
&$\;$\hfil{\tt #}\hfil$\;$%
&$\;$\hfil{\tt #}\hfil$\;$%
&$\;$\hfil{\tt #}\hfil$\;$%
&$\;$\hfil{\tt #}\hfil$\;$%
&$\;$\hfil{\tt #}\hfil$\;$%
&$\;$\hfil{\tt #}\hfil$\;$%
&$\;$\hfil{\tt #}\hfil$\;$%
&$\;$\hfil{\tt #}\hfil$\;$%
&$\;$\hfil{\tt #}\hfil$\;$%
&$\;$\hfil{\tt #}\hfil$\;$%
&\vrule#\cr
\multispan{15}\hrulefill\cr
%\omit&height2pt&\multispan{17}&\cr
&&\phantom{*}&&&&&&&&&&&&&\cr
&&&\phantom{*}&&&&&&&&&&&&\cr
&&\phantom{*}&&&&&&&&&&&&&\cr
&&&&&&&&&&&&&*&*&\cr
&&&&&&&&&&&*&*&*&&\cr
&&&&&&&&&&*&*&&&&\cr
&&&&&&&&*&*&*&&&&&\cr
&&&&&&*&*&*&&&&&&&\cr
&&&&&*&*&&&&&&&&&\cr
&&&*&*&*&&&&&&&&&&\cr
&&\phantom{*}&&&&&&&&&&&&&\cr
\multispan{15}\hrulefill\cr
}}$$

\bigskip
\noindent One satisfactory method is to print a character in each rectangle
of the page grid through which the line passes. These rectangles can be
found by finding the points where $10X$ or $6Y$ take on integer values.
The figure \_\_\_
shows how the line $X-Y=1$ is printed. Notice how the
position $R=3$, $C=5$ is shaded, but not the position $R=4$, $C=6$. Why?

{\rmn
{\narrower\smallskip\noindent
{\bf Exercise:} Given the endpoints $(X1,Y1)$ and $(X2,Y2)$ of a line
segment, print the image of the segment. Make sure it works correctly
even if the segment is horizontal, vertical, or a single point; if it passes
through a grid point; and if it ends on a grid line or point.
\smallskip}
}

To print a region like the interior of a circle, one method is to print a
character in a grid element if more than half the element is in the region;
a~simpler method likely to be as satisfactory is to print a character if
the center of the element is in the region. To print the circular region
$(X-5)↑2+(Y+3)↑2≤2↑2$ one might, for each element $(R,C)$ compute
$X={C-1/2\over 10}$, $Y={-(R-1/2)\over 6}$, and print if the inequality
is satisfied.

\noindent [Illustrate.]

{\rmn
{\narrower\smallskip\noindent
{\bf Exercise:} The Lissajous figures are the parametric curves
$$\eqalign{x&=\sin at\cr
y&=\cos bt\cr}$$
where $a$ and $b$ are positive integers. Scale the figure to occupy a
square 48~characters high on a printed page. Print it, using an asterisk
in every rectangle of the page grid through which the figure passes. 
A~suggested approach: after scaling, the figure enters new rectangles of the
page grid when $x$ or~$y$ are integers. Find, by using inverse functions,
the next value of~$t$ making $x$ or~$y$ an integer.
\smallskip}
}


\bigskip
\line{\copyright 1984 Robert W. Floyd\hfill}
\line{First draft (not published) March 26, l985.\hfill}

\bye